<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        li {
            width: 500px;
            height: 40px;
            line-height: 40px;
            border-bottom: 1px solid red;
        }
    </style>
</head>

<body>
    <ul>
        <li>1111</li>
        <li>2222</li>
        <li>3333</li>
        <li>4444</li>
    </ul>
    <script>
        // 需求：单击任意一个li，获取当前li标签内的文字内容
        /**
         * 1. 如何获取标签内的文字内容？ innerText  / innerHTML
         * 2. 如何获取当前点击的li的内容？
         */

        var oLis = document.querySelectorAll('li');
        // oLis[0].onclick = function () {
        //     console.log(this.innerText);
        // }
        // oLis[1].onclick = function () {
        //     console.log(this.innerText);
        // }
        // oLis[2].onclick = function () {
        //     console.log(this.innerText);
        // }
        // oLis[3].onclick = function () {
        //     console.log(this.innerText);
        // }

        for (var i = 0; i < oLis.length; i++) {
            oLis[i].onclick = function () {
                // console.log(this.innerText);
                console.log(oLis[i].innerHTML);
            }
        }
        console.log(i);
    </script>
</body>

</html>